package org.classg.edu.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.classg.edu.entity.Subject;
import org.classg.edu.service.SubjectService;
import org.classg.edu.vo.SubjectOneVo;
import org.classg.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-05-14
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
@Api(description = "课程分类管理")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    // 添加课程分类
    @ApiOperation("添加课程分类")
    @PostMapping("/insertSubject")
    public R insertSubject(@ApiParam(name = "file", value = "Excel文件", required = true) MultipartFile file) {
        subjectService.insertService(file, subjectService);
        return R.ok();
    }

    // 查看课程分类列表（树形）
    @ApiOperation("查看课程分类列表（树形）")
    @GetMapping("/querySubjectTree")
    public R querySubjectTree() {
        List<SubjectOneVo> list = subjectService.queryAllSubject();
        return R.ok().data("items", list);
    }

    // 查看课程分类列表（树形）
    @ApiOperation("查看课程分类列表（树形）")
    @GetMapping("/querySubjectTree2")
    public R querySubjectTree2() {
        List<Subject> list = subjectService.queryAllSubject2();
        return R.ok().data("items", list);
    }
}

